package com.lyz.dataStructure.algorithm.yitu2020;/**
 * @Author:759057893@qq.com Lyz
 * @Date: ${Date} 19:38
 * @Description:
 **/

import java.util.Scanner;

/**
 *@Author:759057893@qq.com Lyz
 *@Date: 2019/8/9 19:38
 *@Description:
 **/
public class Main1 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
          while (sc.hasNext()){
              String s =  sc.next();
              int count = 0;
              int max =0;
              for(int i =0;i<s.length()-1;i++){
                  if(s.charAt(i)=='Y'&&s.charAt(i+1)=='T'){
                      count++;
                  }
                  Math.max(max,count);
                  if((s.charAt(i) =='Y'&&s.charAt(i+1) =='Y')||(s.charAt(i) =='T'&&s.charAt(i+1) =='T')) {
                      count = 0;
                  }
                  max =  Math.max(max,count);
              }
              System.out.println(max*2);
          }
        }
}
